package com.aisile.manager.controller;

import com.aisile.entity.PageResult;
import com.aisile.entity.Result;
import com.aisile.pojo.TbBrand;
import com.aisile.pojogroup.Specifacation;
import com.aisile.sellergoos.service.BrandService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("brand")
public class BrandController {
    @Reference
    BrandService brandService;

    @RequestMapping("findAll")
    public List<TbBrand> findAll(){
        List<TbBrand> all=brandService.findAll();
        return all;
    }
    @RequestMapping("findPage")
    public PageResult findPage(int page,int rows,@RequestBody TbBrand brand){
        return brandService.findPage(page,rows,brand);
    }
    @RequestMapping("save")
    public Result save(@RequestBody TbBrand tbBrand){
        try {
            brandService.save(tbBrand);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }
    @RequestMapping("findOne")
    public TbBrand findOne(Long id){
        return brandService.findOne(id);
    }
    @RequestMapping("update")
    public Result update(@RequestBody TbBrand tbBrand){
        try {
            brandService.update(tbBrand);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }
    @RequestMapping("dele")
    public Result dele(Long[] ids){
        try {
            brandService.dele(ids);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }

}
